/**
 * 
 */
package de.cbf.cam.dsa.entity.edit.sf.resolver.comparables;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import de.cbf.cam.dsa.facet.sf.FacetSf;
import de.cbf.util.condition.comparable.entities.ConditionComparable;
import de.cbf.util.condition.comparable.interfaces.IConditionComparableProvider;

/**
 * @author Alti
 * TODO load current Sf from database and provide them
 */
public class ConditionComparableProvider_Sf implements
		IConditionComparableProvider {
	private static final Log logger = LogFactory.getLog(ConditionComparableProvider_Sf.class);
	
	public static final String CATEGORY_COMBAT = "Combat";
	public static final String CATEGORY_CIVIL = "Civil";
	
	/**
	 * 
	 */
	public ConditionComparableProvider_Sf() {
		
	}

	/* (non-Javadoc)
	 * @see de.cbf.util.condition.comparable.interfaces.IConditionComparableProvider#provideConditionComparables()
	 */
	@Override
	public Collection<ConditionComparable> provideConditionComparables() {
		List<ConditionComparable> resultList = new ArrayList<ConditionComparable>();
		//add categories
		ConditionComparable parentCivil = new ConditionComparable(CATEGORY_CIVIL);
		resultList.add(parentCivil);
		ConditionComparable parentCombat = new ConditionComparable(CATEGORY_COMBAT);
		resultList.add(parentCombat);
		//add entries
		List<FacetSf> loadedSfs = loadCurrentSfs();
		for (FacetSf facetSf : loadedSfs) {
			ConditionComparable newEntry = new ConditionComparable(facetSf.getName());
			switch (facetSf.getSfType()) {
				case COMBAT:{
					newEntry.setParent(parentCombat);
					parentCombat.addChildComparable(newEntry);
					resultList.add(newEntry);
					break;
				}
				
				case CIVIL:{
					newEntry.setParent(parentCivil);
					parentCivil.addChildComparable(newEntry);
					resultList.add(newEntry);
					break;
				}					
				default:
					logger.error("Unknown sfType: "+facetSf.getSfType());
					break;
			}
		}
		
		return resultList;
	}

	protected List<FacetSf> loadCurrentSfs() {		
		List<FacetSf> resultList = new ArrayList<FacetSf>();
		
		return resultList;
	}

}
